<!DOCTYPE html>
<html>
<head>
    <title>签到</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/myInfo.css"/>
    <link rel="stylesheet" href="/css/myProfiles.css"/>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <link rel="stylesheet" href="../js/plugins/dialog2/dialog.css">
    <script src="../js/plugins/dialog2/dialog.min.js"></script>
    <link rel="stylesheet" href="../css/message.css">
</head>
    <script>

        $(function () {
            var tempstr = sessionStorage.getItem("signtemp")
            var signtemp = 0;
            //解决每次进入页面发请求的问题,可注释
           if(tempstr){
                signtemp=1;
            }
            if(signtemp==0) {
                $.post("/sign/", function (data) {
                    if (data.success) {

                        signtemp=1;
                        sessionStorage.setItem("signtemp",JSON.stringify(signtemp))
                        console.log(signtemp);
                        var source = 2;
                        var signCount = data.data.signcount;
                        if (signCount == 3) {
                            $(document).dialog({
                                titleText: '温馨提示',
                                type: 'confirm',
                                closeBtnShow: true,
                                content: '你已连续签到3天,点击领取滑稽抱枕',
                                onClickConfirmBtn: function () {
                                    $.post("/packsack/sign", {'userId': userId, source: source}, function (data) {
                                        $(document).dialog({
                                            titleText: '温馨提示',
                                            type: 'confirm',
                                            closeBtnShow: true,
                                            content: '领取成功,去我的物品查看',
                                            onClickConfirmBtn: function () {
                                                window.location.href = "/mine/packsack.html";
                                            }
                                        });
                                    })
                                },
                                onClickCancelBtn: function () {
                                    $(document).dialog({
                                        titleText: '温馨提示',
                                        content: '猪猪侠没有了',
                                    });
                                },
                                onClickCloseBtn: function () {
                                    $(document).dialog({
                                        titleText: '温馨提示',
                                        content: '猪猪侠没有了',
                                    });
                                }
                            });
                        } else {
                            var msg = "签到成功,您以连续签到" + signCount + "天!"
                            $(document).dialog({
                                titleText: '温馨提示',
                                content: msg,
                            });
                        }

                    } else {
                        var msg = data.msg;
                        $(document).dialog({
                            titleText: '温馨提示',
                            content: msg,
                        });
                        signtemp=1;
                        sessionStorage.setItem("signtemp",JSON.stringify(signtemp))
                    }
                })
            }
        })
    </script>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-5">
            <a href="../mine/profiles.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>

        </div>
        <span style="text-align: center">签到</span>
    </div>
</div>

<form action="/images" method="post" enctype="multipart/form-data" id="uploadForm">
    <input type="file" style="display: none" id="uploadInput" name="image"/>
</form>
<div class="container info">
    <div class="myBg2">
    </div>
</div>
<ul class="mainmenu">
    <li><a href="/mine/myiintegral.html"><b><i class="fa fa-star fa-2x"></i></b><span>我的积分</span></a></li>
    <li><a href="/mine/product.html"><b><i class="fa fa-commenting-o fa-2x"></i></b><span>前往积分商城</span></a></li>
    <li><a href="/travelPage.html"><b><i class="fa fa-book fa-2x"></i></b><span>看游记</span></a></li>
</ul>

<script>
    var userStr = sessionStorage.getItem("user");
    var user;
    if (userStr) {
        user = JSON.parse(userStr);
        userId=user.id
        $(".info").renderValues(user);
        $(".myBg2").css("background", "url('/upload/e7c7b18849c9c0ebd05fddc2f0d2ce66.png')")
    }
</script>

</body>
</html>
